package com.mq.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mq.model.User;
import com.mq.redis.queue.bean.RedisQueue;
import com.mq.service.RedisService;

//@RunWith(SpringRunner.class)
//@SpringBootTest
@Controller
@RequestMapping(value = "/user")
public class RedisTestAction<T, V> {

	@Autowired
	RedisService redisService;

	@Autowired
	private RedisTemplate<String, Object> redisTemplate;

	@Autowired
	RedisQueue<String, V> redisQueue;

	@RequestMapping(value = "/test")
	public void test() throws Exception {

		// redisService.addUser(new User("1", "何文飞", 27));
		redisQueue.pushFromHead("test:app1");
		redisQueue.pushFromHead("test:app2");
		redisQueue.pushFromHead("test:app3");
		redisQueue.pushFromHead("test:app4");
		//Thread.sleep(15000);
		redisQueue.pushFromHead("test:appA");
		redisQueue.pushFromHead("test:appB");
		redisQueue.pushFromHead("test:appC");
		redisQueue.pushFromHead("test:appD");
		
		//Thread.sleep(15000);
		//redisQueue.destroy();

		System.out.println("redis cache END..." + redisQueue);
	}

}
